package com.qf;

import com.qf.utils.JedisPoolUtil;

import jdk.nashorn.internal.scripts.JD;
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
import org.junit.Test;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

import java.util.HashMap;
import java.util.Map;

public class demo {


    @Test
    public void test(){

        Jedis jedis = JedisPoolUtil.getResource();
        jedis.set("my", "tom");
        jedis.getSet("my","jim");
        System.out.println(jedis.get("my"));
        System.out.println(jedis.mset("my1", "qqq", "my2", "www"));
        System.out.println(jedis.get("my2"));
        jedis.set("my3","eee");

        System.out.println(jedis.set("my5", "vvv", "nx"));
        System.out.println("------------------");
        System.out.println(jedis.set("my6", "ooo", "nx", "px", 200));

        jedis.close();
    }

    @Test
    public void testHash(){
        Jedis jedis = JedisPoolUtil.getResource();
        System.out.println(jedis.hset("pig", "name", "peppy"));
        Map<String,String> map = new HashMap<>();
        map.put("name","peppa");
        map.put("color","black");
        map.put("height","20");
        System.out.println(jedis.hmset("pig", map));
        System.out.println(jedis.hgetAll("pig"));

        jedis.close();
    }


}
